﻿Imports System.Data
Imports System.Data.Odbc
Imports WSEntidades
Imports Utilerias
Imports Npgsql
Imports MySql.Data.MySqlClient
Public Class UdeMFact
    Public Shared Function Build(ByVal dr As MySqlDataReader) As UdeMBE
        Dim tmpUdeM As UdeMBE = New UdeMBE()
        Try
            tmpUdeM = buildInternal(dr.Item("IdUdeM"),
                                    dr.Item("DesUdeM"),
                                    dr.Item("Status"))
            Return tmpUdeM
        Catch ex As Exception
            Throw
        Finally
            tmpUdeM = Nothing
        End Try
    End Function

    Public Shared Function buildInternal(ByVal IdUdeM As Object, ByVal descrUdeM As Object, ByVal estatus As Object) As UdeMBE
        Dim tmpUdeM As UdeMBE = New UdeMBE()
        Try
            With tmpUdeM
                .IdUdeM = convertDTFromDb.convertInt32(IdUdeM)
                .DesUdeM = convertDTFromDb.ConvertString(descrUdeM)
                Select Case convertDTFromDb.ConvertString(estatus)
                    Case "A"
                        .Status = UdeMBE.EstatusUdeM.Activa
                    Case "I"
                        .Status = UdeMBE.EstatusUdeM.Inactiva
                    Case Else
                        .Status = UdeMBE.EstatusUdeM.Inactiva
                End Select
            End With
            Return tmpUdeM
        Catch ex As Exception
            Throw
        Finally
            tmpUdeM = Nothing
        End Try
    End Function
End Class
